package com.skycode7.servlet;

import com.skycode7.dao.AdminDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/adminDel.jsp")
public class AdminDelServlet extends HttpServlet {
    private String adminId;
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        String adminId = req.getParameter("adminId");
        Integer Integet = null;
        int result = new AdminDao().delete(Integet.parseInt(adminId));
        if(result >0){
            resp.sendRedirect("adminList.jsp");
        }else{
            req.getRequestDispatcher("adminDel.jsp").forward(req, resp);
        }
    }
}
